package com.volkanic.screens;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.volkanic.background.BackgroundImage;
import com.volkanic.buttons.Button;

/**
 * Created by Lucas on 19/07/2014.
 */
public class MenuScreen implements Screen {

    private static final String TAG = "MenuScreen";
    private final float XCENTER = Gdx.graphics.getWidth() / 2;

    private Game _game;
    private SpriteBatch batch;
    private Stage stage;
    private Button playButton, highscoreButton, multiPlayerButton, exitButton;

    public MenuScreen (Game game){
        Gdx.app.debug(TAG, "MenuScreen Constructor");
        _game = game;
    }

    @Override
    public void render(float delta) {
        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
            stage.act();
            batch.begin();
            stage.draw();
            batch.end();

    }

    @Override
    public void resize(int width, int height) {

    }

    @Override
    public void show() {
        Texture night = new Texture(Gdx.files.internal("textures/night-sky.png"));
        Image nightSky = new Image(night);
        nightSky.setCenterPosition(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight() - (night.getHeight()/2));



        Gdx.app.debug(TAG, "MenuScren.show");

        // initialize the new stage
        stage = new Stage();

        stage.addActor(nightSky);

        Gdx.input.setInputProcessor(stage);

        playButton.getButton().addListener(new InputListener(){
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                Gdx.app.debug(TAG, "playButton " + playButton.getButton().getY());
                Gdx.app.debug(TAG, "highscoreButton " + highscoreButton.getButton().getY() + highscoreButton.getButton().getHeight());
                return true;
            }
        });

        batch = new SpriteBatch();
    }

    @Override
    public void hide() {

    }

    @Override
    public void pause() {
        _game.pause();
    }

    @Override
    public void resume() {
        _game.resume();
    }

    @Override
    public void dispose() {

    }
}
